package Homework;

import java.util.Scanner;

/**
 * @program: Java_Study
 * @author: Xiaofan
 * @createTime: 2021-07-06 20:29
 * @description: Functions of this class is 有序数组插入元素
 **/
public class B2 {
    public static void main(String args[]){
        Scanner scanner=new Scanner(System.in);
        while (scanner.hasNext()){
            int n=scanner.nextInt();
            int nums[]=new int[n+1];
            int index=0;
            for(int i=0;i<n;i++){
                nums[i]=scanner.nextInt();
            }
            int num=scanner.nextInt();
            for(int i=0;i<=n;i++){
                if(num<=nums[i]){
                    index=i;
                   for(int j=n;j>i;j--){
                       nums[j]=nums[j-1];
                   }
                   break;
                }
            }
            nums[index]=num;
            for(int i=0;i<=n;i++){
                System.out.print(nums[i]+" ");
            }
            System.out.println();
        }
    }
}